//
//  IssueJobCollectionViewCell.m
//  PYWGetColor
//
//  Created by appleLJ on 2018/6/14.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "IssueJobCollectionViewCell.h"

@interface IssueJobCollectionViewCell()
@property(nonatomic,strong) UIImageView *bgImgView;
@property(nonatomic,strong) UILabel *titleLabel;
@end

@implementation IssueJobCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.titleLabel];
        [self addSubview:self.bgImgView];
        __weak __typeof(self)weakSelf = self;
        [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.equalTo(weakSelf);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(weakSelf.bgImgView);
        }];
    }
    return self;
}
#pragma mark -- init
- (UIImageView *)bgImgView{
    if (!_bgImgView) {
        _bgImgView = [[UIImageView alloc] init];
        _bgImgView.layer.borderColor = getColor(bgColor).CGColor;
        _bgImgView.layer.borderWidth = 1;
    }
    return _bgImgView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = DEF_FontSize_14;
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

// setter

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.titleLabel.text = model[@"title"];
    if ([model[@"value"] isEqualToString:@"1"]) {
        self.bgImgView.image = [UIImage imageNamed:@"WechatIMG88x19"];
        _bgImgView.layer.borderColor = [UIColor clearColor].CGColor;
        _bgImgView.layer.borderWidth = 0;
    }else{
        self.bgImgView.image = [UIImage imageNamed:@""];
        _bgImgView.layer.borderColor = getColor(bgColor).CGColor;
    }
    
}

@end
